#pragma once
#include <windows.h>
#include <Vfw.h>
#include "stdafx.h"
class AviMovie{
public:
	AviMovie(const char* filename);
	AviMovie(const char* filename,
				unsigned uWidth,
				unsigned uHeight,
				unsigned uScale,
				unsigned uRate,
				unsigned uLength);
	~AviMovie(void);
	void getNextFrameYUV(byte* pFrameY,byte* pFrameU,byte* pFrameV);
	void putNextFrameYUV(byte* pFrameY,byte* pFrameU,byte* pFrameV);
	unsigned getFrameNum(void);
	unsigned getHeight();
	unsigned getWidth();
	unsigned getScale();
	unsigned getRate();
	unsigned getLength();
	unsigned getPlaneSize();
private:
	PAVIFILE m_aviFile;
	PAVISTREAM m_VideoStream;
	AVIFILEINFO m_aviFileInfo;
	unsigned m_uWidth;
	unsigned m_uHeight;
	unsigned m_uScale;
	unsigned m_uRate;
	unsigned m_uLength;
	unsigned m_uFrameSize;
	unsigned m_uPlaneSize;
	unsigned m_uCurrentFrameNum;
	byte* m_pFrameContainer;
	static unsigned m_suObjectCounter;
	enum openMode{Read,Write} m_bOpenMode;

	byte round(double dValue);
	void readHeader();
	void writeHeader(unsigned uWidth,unsigned uHeight,unsigned uScale,unsigned uRate,unsigned uLength);
};

